package day14.homework02.test02;

import java.util.concurrent.locks.Lock;

/**
 * @author Xiao
 * @date 2021/8/7
 */
public class Girl implements Runnable{
    private Lock lock1;
    private Lock lock2;
    public Girl(Lock lock1, Lock lock2) {
        this.lock1 = lock1;
        this.lock2 = lock2;
    }
    @Override
    public void run() {
        while (true) {
            synchronized (lock1) {
                synchronized (lock2) {
                    System.out.println("小薇正在走路。。。");
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
